<?php /* Smarty version Smarty-3.0.7, created on 2017-06-01 09:25:45
         compiled from "C:\wamp\www\gongzhonghao.yuanfenba.net/modules/admin/tpl/menu/manager.tpl" */ ?>
<?php /*%%SmartyHeaderCode:6447592f6d199c20a4-67507205%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '435d8844d6fa6f4cf70dceb166da3bcff7b8605a' => 
    array (
      0 => 'C:\\wamp\\www\\gongzhonghao.yuanfenba.net/modules/admin/tpl/menu/manager.tpl',
      1 => 1496280090,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '6447592f6d199c20a4-67507205',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
<?php $_template = new Smarty_Internal_Template("header.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate();?><?php unset($_template);?>
<link rel="stylesheet" href="/admin/css/weixin.css"/>
<style>
    .table th,.table td { text-align: center;vertical-align: middle !important; }
</style>
<script type="text/javascript" src="/js/template.js"></script>
<div class="row no-margin">
    <div class="menu_action">
        <a class="btn btn-success" id="only_save">保存</a>
        <a class="btn btn-success" id="release">保存并发布</a>
    </div>
    <div class="menu_setting_area">
        <div class="menu_preview_area">
            <div class="mobile_menu_preview">
                <div class="mobile_hd"><?php echo $_smarty_tpl->getVariable('data')->value['name'];?>
</div>
                <div class="mobile_bd">
                    <ul class="pre_menu_list flex">
                        <?php if (!empty($_smarty_tpl->getVariable('menuList',null,true,false)->value)){?>
                            <?php  $_smarty_tpl->tpl_vars['value'] = new Smarty_Variable;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('menuList')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['value']->key => $_smarty_tpl->tpl_vars['value']->value){
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['value']->key;
?>
                                <li class="pre_menu_item menu_item flex-1 <?php if (!$_smarty_tpl->tpl_vars['key']->value){?>active<?php }?>" data-name="<?php echo $_smarty_tpl->tpl_vars['value']->value['mname'];?>
"
                                    <?php if (!empty($_smarty_tpl->tpl_vars['value']->value['type'])){?>data-type='<?php echo $_smarty_tpl->tpl_vars['value']->value['type'];?>
'<?php }?>
                                    <?php if (!empty($_smarty_tpl->tpl_vars['value']->value['value'])){?>data-value='<?php echo $_smarty_tpl->tpl_vars['value']->value['value'];?>
'<?php }?>
                                    <?php if (!empty($_smarty_tpl->tpl_vars['value']->value['id'])){?>data-key='<?php echo $_smarty_tpl->tpl_vars['value']->value['id'];?>
'<?php }?>
                                    <?php if (!empty($_smarty_tpl->tpl_vars['value']->value['id'])){?>data-id='<?php echo $_smarty_tpl->tpl_vars['value']->value['id'];?>
'<?php }?>>
                                    <a class="pre_menu_link menu_link" href="javascript:;"><span><?php echo $_smarty_tpl->tpl_vars['value']->value['mname'];?>
</span></a>
                                    <div class="sub_menu_box">
                                        <ul class="sub_menu_list">
                                            <?php if (!empty($_smarty_tpl->tpl_vars['value']->value['sub_button'])){?>
                                                <?php  $_smarty_tpl->tpl_vars['sub'] = new Smarty_Variable;
 $_smarty_tpl->tpl_vars['k'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['value']->value['sub_button']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['sub']->key => $_smarty_tpl->tpl_vars['sub']->value){
 $_smarty_tpl->tpl_vars['k']->value = $_smarty_tpl->tpl_vars['sub']->key;
?>
                                                <li class="sub_menu_item" data-name="<?php echo $_smarty_tpl->tpl_vars['sub']->value['mname'];?>
" data-type="<?php echo $_smarty_tpl->tpl_vars['sub']->value['type'];?>
"
                                                    <?php if (!empty($_smarty_tpl->tpl_vars['sub']->value['value'])){?>data-value='<?php echo $_smarty_tpl->tpl_vars['sub']->value['value'];?>
'<?php }?>
                                                    <?php if (!empty($_smarty_tpl->tpl_vars['sub']->value['id'])){?>data-keyword='<?php echo $_smarty_tpl->tpl_vars['sub']->value['id'];?>
'<?php }?>
                                                    <?php if (!empty($_smarty_tpl->tpl_vars['sub']->value['id'])){?>data-id='<?php echo $_smarty_tpl->tpl_vars['sub']->value['id'];?>
'<?php }?>>
                                                    <a class="sub_menu_link menu_link"><span><?php echo $_smarty_tpl->tpl_vars['sub']->value['mname'];?>
</span></a>
                                                </li>
                                                <?php }} ?>
                                            <?php }?>
                                            <li class="sub_menu_item no-extra <?php if (!empty($_smarty_tpl->tpl_vars['value']->value['sub_button'])&&(count($_smarty_tpl->tpl_vars['value']->value['sub_button'])>=5)){?>hidden<?php }?>">
                                                <a class="sub_menu_link menu_link js_addLBtn" title="最多添加5个子菜单"><i class="glyphicon glyphicon-plus"></i></a>
                                            </li>
                                        </ul>
                                        <i class="arrow arrow_out"></i>
                                        <i class="arrow arrow_in"></i>
                                    </div>
                                </li>
                            <?php }} ?>
                        <?php }else{ ?>
                            <li class="pre_menu_item menu_item flex-1 active" data-name="菜单名称" data-type="view">
                                <a class="pre_menu_link menu_link" href="javascript:;"><span>菜单名称</span></a>
                                <div class="sub_menu_box">
                                    <ul class="sub_menu_list">
                                        <li class="sub_menu_item no-extra">
                                            <a class="sub_menu_link menu_link js_addLBtn" title="最多添加5个子菜单"><i class="glyphicon glyphicon-plus"></i></a>
                                        </li>
                                    </ul>
                                    <i class="arrow arrow_out"></i>
                                    <i class="arrow arrow_in"></i>
                                </div>
                            </li>
                        <?php }?>
                        <li class="pre_menu_item flex-1 no-extra <?php if (!empty($_smarty_tpl->getVariable('menuList',null,true,false)->value)&&(count($_smarty_tpl->getVariable('menuList')->value)>=3)){?>hidden<?php }?>">
                            <a class="pre_menu_link menu_link js_addL1Btn" title="最多添加3个一级菜单" href="javascript:;"><i class="glyphicon glyphicon-plus"></i></a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="menu_form_area">
            <div class="shade_tips"><p>点击左侧菜单进行编辑操作</p></div>
            <div class="widget flat">
                <div class="widget-header" style="background-color: #eee;">
                    <span class="widget-caption">编辑菜单</span>
                    <div class="widget-buttons buttons-bordered">
                        <button class="btn btn-danger btn-xs btn-del">删除菜单</button>
                    </div>
                </div>
                <div class="widget-body">
                    <div id="js_preMenuTips" class="pre_menu_tips hidden">已添加子菜单，仅可设置菜单名称。</div>
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right" for="name">菜单名称</label>
                            <div class="col-sm-10">
                                <input type="text" name="name" id="name" class="form-control" autocomplete="off">
                                <p class="help-block help-block-name">字数不超过4个汉字或8个字母</p>
                            </div>
                        </div>
                        <div class="form-group no-padding">
                            <label class="col-sm-2 control-label no-padding-right" for="name">菜单内容</label>
                            <div class="col-sm-10">
                                    <span class="control-group" style="margin-left: 20px;">
                                        <div class="radio line-radio">
                                            <label class="no-padding">
                                                <input type="radio" value="3" name="status" autocomplete="off">
                                                <span class="text">发送消息</span>
                                            </label>
                                        </div>
                                        <div class="radio line-radio">
                                            <label>
                                                <input type="radio" value="1" name="status" autocomplete="off">
                                                <span class="text">跳转网页</span>
                                            </label>
                                        </div>
                                        <div class="radio line-radio">
                                            <label>
                                                <input type="radio" value="2" name="status" autocomplete="off">
                                                <span class="text">图文</span>
                                            </label>
                                        </div>
                                    </span>
                            </div>
                        </div>
                        <div class="menu_content_container">
                            <div class="menu_content menu_content_edit">
                                <label class="col-sm-2 control-label no-padding-right" for="name"></label>
                                <div class="menu_edit col-sm-10">
                                    <ul class="tab_navs">
                                        <li class="tab_nav tab_text active">
                                            <a onclick="return false;" href="javascript:void(0);">
                                                <i class="icon_msg_sender"></i>
                                                <span class="msg_tab_title">文字</span>
                                            </a>
                                        </li>
                                    </ul>
                                    <div class="tabs_content">
                                        <div class="tab_type tab_type_text">
                                            <textarea class="text_txt" id="text_txt" autocomplete="off"></textarea>
                                            <div class="footer_toolbar">
                                                <a class="icon_emotion" href="javascript:void(0);">表情</a>
                                                <p class="text_tip">还可以输入<em>600</em>字</p>
                                                <div class="emotion_area hidden">
                                                    <ul class="emotions">
                                                        <?php  $_smarty_tpl->tpl_vars['vo'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('emotions')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['vo']->key => $_smarty_tpl->tpl_vars['vo']->value){
?>
                                                            <li class="emotions_item">
                                                                <i class="emotion_i" style="background-position:-<?php echo $_smarty_tpl->getVariable('key')->value*24;?>
px 0;"
                                                                   data-title="<?php echo $_smarty_tpl->tpl_vars['vo']->value['title'];?>
" data-gifurl="<?php echo $_smarty_tpl->tpl_vars['vo']->value['gifurl'];?>
"></i>
                                                            </li>
                                                        <?php }} ?>
                                                    </ul>
                                                    <span class="emotions_preview">
                                                        </span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="menu_content menu_content_url hidden">
                                <label class="col-sm-2 control-label no-padding-right" for="name"></label>
                                <div class="menu_url col-sm-10">
                                    <p>指定点击此菜单时要跳转的链接（注：链接需加http://）</p>
                                    <div class="row">
                                        <label class="col-md-2 frm_label">页面地址</label>
                                        <div class="col-md-10 frm_controls">
                                            <input type="text" id="site_url" name="site_url" class="form-control" autocomplete="off"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="menu_content menu_content_url hidden">
                                <label class="col-sm-2 control-label no-padding-right" for="name"></label>
                                <div class="menu_url col-sm-10" style="text-align: center">
                                    <div class="news-preview" id="news-preview">
                                    </div>
                                    <a href="javascript:;" id="sel_article">选择文章</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="art_box" style="position: fixed;top: 5%;left:5%;right: 5%;bottom: 5%;z-index: 100;background-color: rgb(255,255,255);display: none;
-webkit-box-shadow:0 0 10px rgba(0, 0, 0, .5);
  -moz-box-shadow:0 0 10px rgba(0, 0, 0, .5);
  box-shadow:0 0 10px rgba(0, 0, 0, .5);">
    <div class="art_widget" style="position: relative;height: 100%;width: 100%;">
        <div class="art_header" style="position: absolute;top:0;height: 60px;border-bottom: 1px solid #ccc;left: 0;width: 100%;padding-top: 15px;padding-left: 5px;">
            <label for="wechatList">选择公众号</label>
            <select id="wechatList" style="width: 200px;">
                <?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('wechatList')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value){
?>
                    <option value="<?php echo $_smarty_tpl->tpl_vars['item']->value['wid'];?>
"><?php echo $_smarty_tpl->tpl_vars['item']->value['name'];?>
</option>
                <?php }} ?>
            </select>
            <label for="menu">选择菜单</label>
            <select id="menu" style="width: 200px;">
                <?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('dataList')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value){
?>
                    <option value="<?php echo $_smarty_tpl->tpl_vars['item']->value['id'];?>
"><?php if ($_smarty_tpl->tpl_vars['item']->value['pid']>0){?>&nbsp;&nbsp;--<?php }?><?php echo $_smarty_tpl->tpl_vars['item']->value['mname'];?>
</option>
                <?php }} ?>
            </select>
        </div>
        <div class="art_con" style="position: absolute;top: 60px;bottom: 40px;left: 0;width: 100%;overflow-y: auto;padding: 5px;overflow-x: hidden;">
            <div class="row">
                <div class="col-xs-6">
                    <h5>选择文章</h5>
                    <table class="fTable table" id="select_article">
                        <thead>
                            <tr>
                                <th width="40%">标题</th>
                                <th width="20%">封面图</th>
                                <th width="20%">类型</th>
                                <th width="20%">操作</th>
                            </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>
                </div>
                <div class="col-xs-6">
                    <h5>已选文章</h5>
                    <table class="fTable table" id="selected_article">
                        <thead>
                        <tr>
                            <th width="40%">标题</th>
                            <th width="20%">封面图</th>
                            <th width="20%">类型</th>
                            <th width="20%">操作</th>
                        </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="art_footer" style="position: absolute;bottom: 0;left:0;width: 100%;height: 40px;border-top: 1px solid #ccc;text-align: right;padding-top: 5px;padding-right: 5px;">
            <a type="button" class="btn btn-default btn-sm" id="btn-close">关闭</a>
            <a type="button" class="btn btn-success btn-sm" id="btn-ok">确定</a>
        </div>
    </div>
</div>
<script type="text/html" id="menuTpl">
    <li class="pre_menu_item menu_item flex-1" data-name="菜单名称" data-type="view">
        <a class="pre_menu_link menu_link" href="javascript:;">
            <span>菜单名称</span>
        </a>
        <div class="sub_menu_box">
            <ul class="sub_menu_list">
                <li class="sub_menu_item no-extra">
                    <a class="sub_menu_link menu_link js_addLBtn" title="最多添加5个子菜单"><i class="glyphicon glyphicon-plus"></i></a>
                </li>
            </ul>
            <i class="arrow arrow_out"></i>
            <i class="arrow arrow_in"></i>
        </div>
    </li>
</script>
<script type="text/html" id="subMenuTpl">
    <li class="sub_menu_item" data-name="子菜单名称">
        <a class="sub_menu_link menu_link" href="javascript:;"><span>子菜单名称</span></a>
    </li>
</script>

<script>
var menu = {
    entity: null,
    shade_tips: $('.shade_tips'),
    set_entity: function(entity){
        this.entity = entity;
        this.form();
        return this;
    },
    form: function(){
        $('input[name="name"]').val(this.get_name());
        var type = this.get_type();
        var status = $('input[name="status"]');
        $('#site_url').val('');
        $('#keyword').val('');
        if(type == 1){
            $('#site_url').val(this.get_value());
            var target = $(status.get(1));
            status.get(1).checked = true;
        }else if(type == 3){
            $('#text_txt').val(this.get_value());
            var target = $(status.get(0));
            status.get(0).checked = true;
        }else if(type == 2){
            var target = $(status.get(2));
            status.get(2).checked = true;
            if(this.get_value()) getArticles(this.get_value());
            else $('#news-preview').html('');
        }
        this.chang_show(target);
        return this;
    },
    set_type: function(type){
        this.entity.data('type',type);
        return this;
    },
    get_type: function(){
        return this.entity.data('type');
    },
    set_name: function(name){
        this.entity.data('name',name);
        this.entity.find(' > .menu_link span').text(name);
        return this;
    },
    get_name: function(){
        return this.entity.data('name');
    },
    set_key: function(key){
        this.entity.data('key',key);
        return this;
    },
    get_key: function(){
        return this.entity.data('key');
    },
    set_value: function(value){
        this.entity.data('value',value);
        return this;
    },
    get_value: function(){
        return this.entity.data('value');
    },
    set_media_id: function(media_id){
        this.entity.data('media_id',media_id);
        return this;
    },
    get_media_id: function(){
        return this.entity.data('media_id');
    },
    chang_show: function(obj){
        this.set_type(obj.val());
        var index = $(obj).closest('.radio').index();
        $($('.menu_content').addClass('hidden').get(index)).removeClass('hidden');
        return this;
    },
    hide_shade: function () {
        this.shade_tips.hide();
        return this;
    },
    show_shade: function () {
        this.shade_tips.show();
        return this;
    },
    show_addBtn: function () {
        this.entity.parent().find('li:last-child').removeClass('hidden');
        return this;
    },
}.set_entity($('.pre_menu_item.active'));
</script>
<script>
    $(function(){
        /*$('.emotions_item').hover(function(){
            $('.emotions_preview').html('<img src="' + $(this).find('i').data('gifurl') + '"/>');
        },function(){
            $('.emotions_preview').html('');
        });
        $('.emotions_item').click(function(){
            var text_txt = $('#text_txt').val();
            var text = $(this).children().data('title');
            $('#text_txt').val(text_txt + '[' + text + ']');
            $('.emotion_area').addClass('hidden');
        });*/
        $('.icon_emotion').click(function(){
            var emotion_area = $('.emotion_area');
            if(emotion_area.hasClass('hidden')){
                emotion_area.removeClass('hidden');
            }else{
                emotion_area.addClass('hidden');
            }
        });
        $('#text_txt').keyup(function () {
            var value = $.trim(this.value);
            menu.set_value(value);
        });
        $('input[name="status"]').change(function(){
            menu.chang_show($(this));
            if($(this).val() == 2){
                var value = menu.get_value();
                if(value) getArticles(value);
            }
        });
        $(document).on('click','.pre_menu_item',function(e){
            var cur_li = $(e.target).closest('li');
            if(!cur_li.hasClass('pre_menu_item')){
                return;
            }
            var ul = $(this).parent();
            if(!$(this).hasClass('no-extra')){
                if($(this).hasClass('active-invalid')) $(this).removeClass('active-invalid');
                cur_li.find('li.active').removeClass('active');

                if(!$(this).hasClass('active')){
                    ul.children('.active').removeClass('active');
                    $(this).addClass('active');
                }
                $('.help-block-name').text('字数不超过4个汉字或8个字母');
                menu.hide_shade().set_entity($(this));
                var widget = $('.menu_form_area').find('.widget');
                if(cur_li.find('ul.sub_menu_list').find('li.sub_menu_item').length > 1){ //判断是否有子菜单
                    widget.find('#js_preMenuTips').removeClass('hidden');
                    widget.find('.form-horizontal > div').hide();
                    widget.find('.form-horizontal > div:first-child').show();
                }else{
                    widget.find('.form-horizontal > div').show();
                    widget.find('#js_preMenuTips').addClass('hidden');
                }
            }else{
                var li = template('menuTpl');
                $(this).before(li);
                ul.children('.active').removeClass('active');
                $(this).prev().addClass('active');
                $('.help-block-name').text('字数不超过4个汉字或8个字母');
                menu.hide_shade().set_entity($(this).prev());
                if(ul.children().length === 4){
                    $(this).addClass('hidden');
                }
            }
        });
        $(document).on('click','.sub_menu_item',function () {
            var parent_ul = $(this).closest('.pre_menu_list');
            var parent_li = $(this).closest('.pre_menu_item');
            var cur_ul = $(this).parent();
            var cur_li = $(this);

            if(!$(this).hasClass('no-extra')){
                if(!$(this).hasClass('active')){
                    parent_li.addClass('active-invalid');
                    cur_ul.children('.active').removeClass('active');
                    $(this).addClass('active');
                    $('.help-block-name').text('字数不超过8个汉字或16个字母');
                    var widget = $('.menu_form_area').find('.widget');
                    widget.find('.form-horizontal > div').show();
                    widget.find('#js_preMenuTips').addClass('hidden');
                    menu.hide_shade().set_entity($(this));
                }
            }else{
                var li = template('subMenuTpl');
                $(this).before(li);
                parent_ul.children('.active').addClass('active-invalid');
                cur_ul.children('.active').removeClass('active');
                $(this).prev().addClass('active');
                $('.help-block-name').text('字数不超过8个汉字或16个字母');
                menu.hide_shade().set_entity($(this).prev());
                if(cur_ul.children().length === 6){
                    $(this).addClass('hidden');
                    cur_ul.parent().find('.arrow').hide();
                }
            }
        });
        $('.btn-del').click(function () {
            if(confirm("确定要删除么?")){
                menu.show_shade().show_addBtn().entity.remove();
            }
        });
        $('input[name="name"]').keyup(function(){
            var value = $.trim(this.value);
            menu.set_name(value);
        });
        $('#site_url').keyup(function(){
            var value = $.trim(this.value);
            menu.set_value(value);
        });
        $('#only_save').click(function(){
            var buttons = getValues();
            if(buttons)
                $.post('',{buttons:buttons,only_save:1},function(result){
                    alert(result.msg);
                    setId(result.idList);
                });
        });
        $('#release').click(function(){
            var buttons = getValues();
            if(buttons)
                $.post('',{buttons:buttons},function(result){
                    alert(result.msg);
                    setId(result.idList);
                });
        });
        function getValues() {
            var buttons = [];
            var menus = $('.pre_menu_list').children();
            for(var i= 0,ilen=(menus.length-1) ;i<ilen;i++){
                buttons[i] = {};
                var name = $(menus[i]).data('name');
                if(name == ''){
                    alert('菜单名称不能为空');
                    return false;
                }
                buttons[i].name = name;
                buttons[i].id = $(menus[i]).data('id');
                var child_menu = $(menus[i]).find('.sub_menu_list').find('.sub_menu_item');
                if(child_menu.length > 1){
                    buttons[i].sub_button = [];
                    for(var j=0,jlen=(child_menu.length-1);j<jlen;j++){
                        buttons[i].sub_button[j] = {};
                        var name = $(child_menu[j]).data('name')
                        if(!name){
                            alert('菜单名称不能为空');
                            return false;
                        }
                        buttons[i].sub_button[j].name = name;
                        buttons[i].sub_button[j].id = $(child_menu[j]).data('id');
                        buttons[i].sub_button[j].type = $(child_menu[j]).data('type');
                        var value = $(child_menu[j]).data('value');
                        if(buttons[i].sub_button[j].type == 1){ //连接地址
                            if(!value || value.indexOf('http://') === -1){
                                alert('页面地址不能为空');
                                return false;
                            }
                            buttons[i].sub_button[j].value = value;
                        }else if(buttons[i].sub_button[j].type == 2){ //触发关键字
                            buttons[i].sub_button[j].value = value;
                        }else if(buttons[i].sub_button[j].type == 3){  //文字
                            buttons[i].sub_button[j].value = value;
                        }
                    }
                }else{
                    buttons[i].type = $(menus[i]).data('type');
                    if(buttons[i].type == 1){ //连接地址
                        var url = $(menus[i]).data('value');
                        if(!url || url.indexOf('http://') === -1){
                            alert('页面地址不能为空');
                            return false;
                        }
                        buttons[i].value = url;
                    }else if(buttons[i].type == 2){ //触发关键字
                        /*var keyword = $(menus[i]).data('keyword');
                        buttons[i].key = keyword;*/
                    }else if(buttons[i].type == 3){  //文字

                    }
                }
            }
            if(buttons.length <= 0){
                alert('请添加菜单');return false;
            }
            return buttons;
        }
        function setId(idList) {
            var menus = $('.pre_menu_list').children();
            var k=0;
            for(var i= 0,ilen=(menus.length-1) ;i<ilen;i++){
                $(menus[i]).data('id',idList[k++]);
                var child_menu = $(menus[i]).find('.sub_menu_list').find('.sub_menu_item');
                if(child_menu.length > 1){
                    for(var j=0,jlen=(child_menu.length-1);j<jlen;j++){
                        $(child_menu[j]).data('id',idList[k++]);
                    }
                }
            }
        }
    });
</script>
<script>
    $(function () {
        $('#sel_article').click(function () {
            var mid = $('#menu').find('option:selected').val();
            change_article(mid);
            $('#art_box').show();
        });
        $('#btn-close').click(function () {
            $('#art_box').hide();
        });
        $('#btn-ok').click(function () {
            var idList = [];
            $('#selected_article').find('tbody tr').each(function () {
                idList.push($(this).data('id'));
            });
            var idStr = idList.join(',');
            if(idList.length) getArticles(idStr);
            menu.set_value(idStr);
            $('#art_box').hide();
        });
        $('#wechatList').change(function () {
            change_article();
        });
        function change_article(mid) {
            $.post('/admin/menu/getArticles',{mid:mid},function (res) {
                if(res.status == 1 && res.dataList.length>0){
                    $('#select_article').find('tbody').html('');
                    for(var i in res.dataList){
                        var title = res.dataList[i].title;
                        var img_thumb_100 = res.dataList[i].img_thumb_100;
                        var type_text = res.dataList[i].type_text;
                        var type = res.dataList[i].type;
                        var id = res.dataList[i].id;
                        $('#select_article').find('tbody').append("<tr data-id=" + id + ">" +
                                "<td>" + title + "</td>" +
                                "<td><img src='" + img_thumb_100 + "' height='40'/></td>" +
                                "<td>" + type_text + "</td>" +
                                "<td><a data-type=" + type + " data-id=" + id + " class='a_sel' href='javascript:;'>添加</a></td>" +
                            "</tr>");
                    }
                }
            });
        }
        $(document).on('click','.a_sel',function () {
            var id=$(this).data('id');
            var is_add = false;
            if($('#selected_article').find('tbody tr').length >= 8){
                return alert('最多添加8篇文章！');
            }
            $('#selected_article').find('tbody tr').each(function () {
                if($(this).data('id') == id) is_add = true;
            });
            if(!is_add){
                var tr = $(this).closest('tr').clone();
                tr.find('td:last-child').html('<a class="a_del" href="javascript:;">删除</a>');
                $('#selected_article').append(tr);
            }else{
                return alert('该文章已添加！');
            }
        });
        $(document).on('click','.a_del',function () {
            $(this).closest('tr').remove();
        });
    });
    function getArticles(idStr) {
        $.post('/admin/menu/getArticlesById',{idStr:idStr},function (res) {
            $('#news-preview').html('<ul class="con-list"></ul>');
            var con_list = $('#news-preview').find('.con-list');
            if(res.status == 1 && res.dataList.length>0){
                $('#select_article').find('tbody').html('');
                for(var i in res.dataList){
                    var title = res.dataList[i].title;
                    var img_thumb = res.dataList[i].img_thumb;
                    var id = res.dataList[i].id;
                    if(i>0)
                        var li= $('<li class="con-item item-con" data-article_id="'+id+'"></li>');
                    else
                        var li= $('<li class="con-item item-con con-item-first" data-article_id="'+id+'"></li>');
                    li.html('<a href="javascript:;">' +
                        '<span class="title">'+title+'</span>' +
                        '<div class="imgpic">' +
                        '<img class="pic_cover" src="'+img_thumb+'">' +
                        '</div>' +
                        '</a>');
                    con_list.append(li);
                }
            }
        });
    }
</script>

<?php $_template = new Smarty_Internal_Template("footer.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate();?><?php unset($_template);?>